package com.example.yls.demoa;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    private RecyclerView stulist;
    private ArrayList<Student> studentArrayList=new ArrayList<>();
    private RecyclerView.Adapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        stulist=findViewById(R.id.stulist);
        inntStuList();
        adapter=new StuAdapter(MainActivity.this,studentArrayList);
        stulist.setAdapter(adapter);
        LinearLayoutManager manager=new LinearLayoutManager(MainActivity.this);

        stulist.setLayoutManager(manager);
    }

    private void inntStuList() {
        Student s1=new Student(18,"张三",R.drawable.dog1);
        Student s2=new Student(16,"张四",R.drawable.dog2);
        Student s3=new Student(15,"张无",R.drawable.dog3);
        Student s4=new Student(14,"张六",R.drawable.dog4);
        Student s5=new Student(13, "张七",R.drawable.dog5);
        studentArrayList.add(s1);
        studentArrayList.add(s2);
        studentArrayList.add(s3);
        studentArrayList.add(s4);
        studentArrayList.add(s5);


    }
}
